import { userInfoAPI } from '@/api/user.js'
export default {
  namespaced: true,
  state() {
    return {
      token: '',
      userInfo: ''// 用户的基本信息
    }
  },
  mutations: {
    // 设置token
    setToken(state, tokenStr) {
      state.token = tokenStr
    },
    // 设置用户的基本信息
    setUserInfo(state, userObj) {
      state.userInfo = userObj
    }
  },
  actions: {
    // 调接口获得用户的信息
    async getUserInfo(store) {
      const { data: { data } } = await userInfoAPI()
      store.commit('setUserInfo', data)
    }
  },
  getters: {}
}
